package com.letoken.platform.admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.admin.req.user.StatusReq;
import com.letoken.platform.repo.admin.req.user.UserIdReq;
import com.letoken.platform.repo.app.po.Video;
import com.letoken.platform.repo.app.po.VideoBackstageAudit;
import com.letoken.platform.repo.utlis.PageDataUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/video")
public class LeVideoController {

    @Resource
    private VideoMapper videoMapper;

    @PostMapping("page")
    private ApiResponse<?> page(@RequestBody UserIdReq req) {
        Page<VideoBackstageAudit> page = new Page<>(req.getPageReq().getPage(), req.getPageReq().getSize());
        videoMapper.backstagePage(page, req.userId);
        return ApiResponse.create(PageDataUtil.getPageData(page));
    }

    @PostMapping("/update/status")
    private ApiResponse<?> page(@RequestBody StatusReq req) {
        Video video = new Video();
        video.setId(req.id);
        video.setStatus(req.status);
        videoMapper.updateById(video);
        return ApiResponse.create();
    }
}
